'use strict';

const Controller = require('egg').Controller;


class UserController extends Controller {
  async index() {
    try {
      // 查询所有的用户
      const list = await this.ctx.service.user.list()
      // await 后面需要跟一个promise
     
      this.ctx.body = {
          code: 1,
          list
      }
      } catch(e) {
          this.ctx.body = {
              code: 0,
              msg: e.message
          }
      }
  }
  async list() {
    try {
        // 查询所有的用户
        const list = await this.ctx.service.user.list()
        // await 后面需要跟一个promise
        console.log(11111,this.ctx.state)

        this.ctx.body = {
            code: 1,
            list
        }
    } catch(e) {
        this.ctx.body = {
            code: 0,
            msg: e.message
        }
    }
  }
}

module.exports = UserController;